/*******************************************************************************
 * Copyright (C) 2013 Jeremy Brodt and Kevin Gillespie
 * $Id: main.c 47 2014-04-29 14:14:46Z kgills@gmail.com $
 *******************************************************************************
 */

#include <stdio.h>

// Maxim CMSIS includes
#include "config.h"
#include "errors.h"
#include "adc.h"
#include "delay.h"

/***** Definitions *****/

/***** Global Variables *****/

/***** Function Prototypes *****/

//******************************************************************************
int main(void)
{
  printf("*** Singularity ADC testing ***\n");

  // Initialize ADC
  if(adc_init(ADC_16) != E_NO_ERROR)
    printf("Error initializing ADC\n");

  int reading;

  while(1)
  {
    if((reading = adc_read(ADC_AN0, 10000)) < 1)
      printf("Error reading ADC\n");
    else
      printf("reading = 0x%x\n",reading);

    delay(MSEC(500));
  }
  return 0;
}
